//
//  Common.swift
//  SwiftDemo
//
//  Created by xxcao on 2016/12/12.
//  Copyright © 2016年 xxcao. All rights reserved.
//


import UIKit
import Foundation

class Common: NSObject {
    class func removeExtraCellLines(TableView table:UITableView){
        //除去TableView多余分割线
        let view : UIView = UIView.init()
        view.backgroundColor = UIColor.clear
        table.tableFooterView = view;
    }
    
    
    //自定义push动画
    class func customPushAnimationFromNavigation(nav:UINavigationController, toViewController vc :UIViewController, type: String, subType: String, duration: Double) {
        let transition:CATransition = CATransition()
        transition.duration = duration
        transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition.type = type
        transition.subtype = subType;
        nav.view.layer.add(transition, forKey: nil)
        nav.pushViewController(vc, animated: false)
    }
    
    //自定义pop动画
    class func customPopAnimationFromNavigation(nav: UINavigationController, type: String, subType: String, duration: Double) {
        let transition:CATransition = CATransition()
        transition.duration = duration
        transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition.type = type;
        transition.subtype = subType;
        nav.view.layer.add(transition, forKey: nil)
        nav.popViewController(animated: false)
    }
    
    class func isAllNum(str:String) -> Bool{
        let scan: Scanner = Scanner(string: str)
        var val:Int = 0
        return scan.scanInt(&val) && scan.isAtEnd
    }
    
    class func isHasQRCode() -> Bool{
        if (globalTuples?.code != nil && (globalTuples?.code.characters.count)! > 0) {
            return true
        }
        return false
    }
    
    class func setPerson(person: User){
        globalTuples?.userId = person.staff_code!
        globalTuples?.person = person.full_name!
        globalTuples?.department = person.user_name!
    }
    
    class func clearGlobalTuples(){
        globalTuples?.person = ""
        globalTuples?.userId = ""
        globalTuples?.department = ""
        globalTuples?.code = ""
        globalTuples?.goodsName = ""
    }
    
    class func getGlobalPersonUserId() -> String {
        return (globalTuples?.userId)!
    }
    
    class func getGlobalGoodsCode() -> String {
        return (globalTuples?.code)!
    }
}



/*
 animation.type = kCATransitionFade;
 animation.type = kCATransitionPush;
 animation.type = kCATransitionReveal;
 animation.type = kCATransitionMoveIn;
 animation.type = @"cube";
 animation.type = @"suckEffect";
 animation.type = @"oglFlip";
 animation.type = @"rippleEffect";
 animation.type = @"pageCurl";
 animation.type = @"pageUnCurl";
 animation.type = @"cameraIrisHollowOpen";
 animation.type = @"cameraIrisHollowClose";
 */

